# json字符串
stu_json = """
{
    "id": "1500100006",
    "name": "边昂雄",
    "age": 21,
    "sex": "男",
    "clazz": "理科二班"
}
"""

# 解析json格式的数据
import json

# 将json字符串转换成python中的对象
stu_obj = json.loads(stu_json)
print(stu_obj, type(stu_obj))

print(stu_obj["name"])
print(stu_obj["age"])
print(stu_obj["sex"])

# 将python对象转换成json字符串
users = [
    {
        "id": "001",
        "name": "张三",
        "age": 23
    },
    {
        "id": "002",
        "name": "李四",
        "age": 24
    }
]

users_json = json.dumps(users, ensure_ascii=False)
print(users_json)
